/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.bluesbruce.so.radio;

import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.DoubleByReference;
import com.sun.jna.ptr.IntByReference;

/**
 * 调用so
 *
 * @author BBF
 */
public class RadioSoJava {

  private static final int DOUBLE_SIZE = Native.getNativeSize(Double.class);
  private static final int FLOAT_SIZE = Native.getNativeSize(Float.class);

  public void zxdqmx(double iyr, double iday, double ihr, double imin, double sec, double xlat,
      double xlon, double xht, double f10, double f10b, double xkp, double temp, double rho,
      double n2, double o2, float[] w) {
    IntByReference s = new IntByReference();

    DoubleByReference p_iyr = new DoubleByReference(iyr);
    DoubleByReference p_iday = new DoubleByReference(iday);
    Pointer p_ihr = new Memory(DOUBLE_SIZE);
    p_ihr.setDouble(0, ihr);
    Pointer p_imin = new Memory(DOUBLE_SIZE);
    p_imin.setDouble(0, imin);
    Pointer p_sec = new Memory(DOUBLE_SIZE);
    p_sec.setDouble(0, sec);
    Pointer p_xlat = new Memory(DOUBLE_SIZE);
    p_xlat.setDouble(0, xlat);
    Pointer p_xlon = new Memory(DOUBLE_SIZE);
    p_xlon.setDouble(0, xlon);
    Pointer p_xht = new Memory(DOUBLE_SIZE);
    p_xht.setDouble(0, xht);
    Pointer p_f10 = new Memory(DOUBLE_SIZE);
    p_f10.setDouble(0, f10);
    Pointer p_f10b = new Memory(DOUBLE_SIZE);
    p_f10b.setDouble(0, f10b);
    Pointer p_xkp = new Memory(DOUBLE_SIZE);
    p_xkp.setDouble(0, xkp);
    Pointer p_temp = new Memory(DOUBLE_SIZE);
    p_temp.setDouble(0, temp);
    Pointer p_rho = new Memory(DOUBLE_SIZE);
    p_rho.setDouble(0, rho);
    Pointer p_n2 = new Memory(DOUBLE_SIZE);
    p_n2.setDouble(0, n2);
    Pointer p_o2 = new Memory(DOUBLE_SIZE);
    p_o2.setDouble(0, o2);
    RadioSo.INSTANCE.zxdqmx_(p_iyr, p_iday, p_ihr, p_imin, p_sec, p_xlat, p_xlon,
        p_xht, p_f10, p_f10b, p_xkp, p_temp, p_rho, p_n2, p_o2, w);
  }
}
